package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.dto.NearFoodTruckQurey;
import org.example.dto.NearFoodTruckVO;
import org.example.model.FoodTruck;
import org.example.service.FoodTruckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("foodTruck")
public class FoodTruckController {
    @Autowired
    private FoodTruckService foodTruckService;

    //根据Applicant 查找
    @GetMapping("queryByApplicant")
    public List<FoodTruck> queryByApplicant(@RequestParam("applicant") String applicant) {
        return foodTruckService.queryByApplicant(applicant);
    }

    //根据多标签查找foodtruck信息
    @GetMapping("queryByFoodItems")
    public List<FoodTruck> queryByFoodItems(@RequestParam("foodItems") List<String> foodItems) {
        return foodTruckService.queryByFoodItems(foodItems);
    }

    // 查找附近的foodtruck
    @PostMapping("nearFoodTruck")
    public List<NearFoodTruckVO> nearFoodTruck(@RequestBody NearFoodTruckQurey query) {
        return foodTruckService.nearFoodTruck(query);
    }
}
